package com.xinqi.modules.prepare.question.controller.web;

import com.xinqi.common.base.dto.QuestionBaseDTO;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.prepare.question.service.PrepareQuestionImportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 备课区docx导入模板
 *
 * @author: wenjie
 * @date: 2023/3/26 11:34
 */
@Tag(name = "Web-备课区-试题库", description = "备课区-试题库Web接口")
@RestController
@RequestMapping("/web/prepare/question")
@RequiredArgsConstructor
public class PrepareQuestionImportWebController {
    private final PrepareQuestionImportService prepareQuestionImportService;

    @Operation(summary = "备课区测评卷导入")
    @PostMapping("/import-word-paper")
    public R<List<QuestionBaseDTO>> importWordPaper(@RequestParam("file") MultipartFile file) throws Exception {
        List<QuestionBaseDTO> prepareList = prepareQuestionImportService.docxToWordImportQuestions(file);
        return R.data(prepareList, "提取成功");
    }
}
